﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Data;
using Maticsoft.DBUtility;
using System.Web.Security;

public partial class account_reset : FBasePage
{


    // Methods
    private void initPage()
    {
        if ((base.Request["code"] != null) && (base.Request["code"].ToString() != ""))
        {
            string str = base.Request["code"].ToString();
            string str2 = "";
            Maticsoft.BLL.UserInfo info = new Maticsoft.BLL.UserInfo();
            DataSet list = info.GetList("Secret='" + str + "'");
            if (((list != null) && (list.Tables.Count > 0)) && (list.Tables[0].Rows.Count > 0))
            {
                DataRow row = list.Tables[0].Rows[0];
                string s = row["id"].ToString();
                Random random = new Random();
                string pwd = "";
                for (int i = 0; i < 8; i++)
                {
                    pwd = pwd + random.Next(0, 9).ToString();
                }
                str2 = pwd;
                pwd = FormsAuthentication.HashPasswordForStoringInConfigFile(pwd + "@4!@#$%@", "md5");
                info.UpdatePwd(int.Parse(s), pwd);
                base.SetSuccess("您的密码已重置！新密码为" + str2);
                base.Response.Redirect("/index.aspx");
            }
        }
    }

    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
        if (!this.Page.IsPostBack)
        {
            this.initPage();
        }
    }

}